package com.smh.a01immutableDemo1;

import java.util.Iterator;
import java.util.Set;

public class ImmutableDemo2 {
    public static void main(String[] args) {

        //元素唯一
        Set<String> set = Set.of("asd","qwe","zxc");

        for (String s : set) {
            System.out.println(s);
        }

        set.forEach(s -> {
            System.out.println(s);
        });

        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }

        set.add("sad");


    }
}
